package com.zz.parkingsystem.util;

/**
 * @author zz
 */
public class ResultGenerator {

    private static final String DEFAULT_SUCCESS_MESSAGE = "SUCCESS";

    private static final String DEFAULT_FAIL_MESSAGE = "FAIL";

    private static final int RESULT_CODE_SUCCESS = 200;

    private static final int RESULT_CODE_SERVER_ERROR = 500;
    /**
     * 返回成功消息
     */
    public static Result<?> genSuccessResult() {
        return new Result<>(RESULT_CODE_SUCCESS, DEFAULT_SUCCESS_MESSAGE);
    }

    /**
     * 成功返回数据
     */
    public static <T> Result<T> genSuccessResult(T data) {
        return new Result<T>(RESULT_CODE_SUCCESS, DEFAULT_SUCCESS_MESSAGE, data);
    }

    public static Result<?> genFailResult() {
        return new Result<>(RESULT_CODE_SERVER_ERROR, DEFAULT_FAIL_MESSAGE);
    }

    public static Result<?> genFailResult(String message) {
        return new Result<>(RESULT_CODE_SERVER_ERROR, message);
    }

    public static <T> Result<T> genCustomerResult(Integer code,String message,T data) {
        return new Result<>(code, message,data);
    }
}
